package util;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

public class Ruter
{
  private Point2D.Double p0;
  private static Color ruteFarge=new Color(199,199,199);
  private static Color lysRuteFarge=new Color(240,240,240);
  
  public static void paintRaster(Graphics2D g,Rectangle2D.Double r,double scale)
  { Ruter ruter=new Ruter(new Point2D.Double(r.x,r.y));
    ruteFarge=Color.white;
    lysRuteFarge=Color.white;
    ruter.paint(g,r.width,r.height,scale);
    ruteFarge=new Color(199,199,199);
    lysRuteFarge=new Color(240,240,240);
  }
  
  public Ruter(Point2D.Double p0)
  { this.p0=p0;
  }
  
  public void paint(Graphics2D g,double width,double height,double scale)
  {
    double d10=0.10*scale;
    double xL=p0.x;
    double yL=p0.y;
    double widthL=width*scale;
    double heightL=height*scale;
    // Horisontale linjer
    { int n=1+(int)(heightL/d10);
      for(int i=0;i<n;i++)
      { if(i==(i/5)*5) g.setColor(ruteFarge);
        else g.setColor(lysRuteFarge);
        Util.drawLine(g, xL,yL+i*d10 ,xL+widthL,yL+i*d10 );
      }
    }
    // Vertikale linjer
    { int n=1+(int)(widthL/d10);
      for(int i=0;i<n;i++)
      { if(i==(i/5)*5) g.setColor(ruteFarge);
        else g.setColor(lysRuteFarge);
        Util.drawLine(g, xL+i*d10,yL ,xL+i*d10,yL+heightL );
      }
    }
    g.setColor(Color.black);
  }
}
